<?php
namespace app\index\controller;
use think\Controller;

class Tags extends Base
{
	//控制器默认方法
    public function index()    
    {   
        //根据标签所在页面传递来的标签分类信息,查询标签分类文章并且将结果分页显示
        $tag = input('tag');
        
        //查询匹配条件
        $where = "a.tags like '%$tag%' AND a.status=1";
        
        //联合查询
        $rec = \think\Db::name('article')->alias('a')
              ->join('category c','a.category = c.id','LEFT')
              ->field('a.id,a.title,c.name_cn as category,a.keywords,a.tags,a.author,a.status,a.thumbnail,a.clicks,a.create_time')
              ->where($where)
              ->paginate(2);
        $this->assign('articles',$rec);
        return $this->fetch();
    }
}